﻿using System;
using System.Collections.Generic;
using System.Text;

namespace hedefgrup.reports.common
{
    public class Criteria_Roll : Criteria
    {
        public Criteria_Roll()
        {
            Values.Add("Yok");
        }

        public override string Name
        {
            get
            {
                return "Roll";
            }
        }

        public override string[] GetValueList()
        {
            return new string[] { "Yok", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "Tümü" };
        }

        public override object ToActualValue()
        {
            return Values[0] == "Yok" ? 0 : Values[0] == "Tümü" ? 20 * 12 : Convert.ToInt32(Values[0]) - 1;
        }

        public override object ToSqlStatementValue()
        {
            if (Report.GetCriteriaByName("Begin Month") == null)
            {
                return (int)(Report.GetCriteriaByName("End Month").ToSqlStatementValue()) - (int)ToActualValue();
            }
            else
            {
                return null;
            }
        }

        public override string ToSqlStatementFilter(ref int parameterOffset)
        {
            if (Report.GetCriteriaByName("Begin Month") == null)
            {
                return "YIL * 12 + AY  >= @p_" + parameterOffset++;
            }
            else
            {
                return null;
            }
        }

        public override string Expression
        {
            get { throw new NotImplementedException(); }
        }

        public override string Operator
        {
            get { throw new NotImplementedException(); }
        }

        public override Type ValueType
        {
            get { return typeof(int); }
        }
    }
}
